Back to Documentation

MCP Provider

Model Context Protocol implementation for UTCP

The MCP (Model Context Protocol) provider enables UTCP to interoperate with services that implement the Model Context Protocol, providing seamless compatibility and bidirectional communication between UTCP and MCP ecosystems for enhanced tool interoperability.

Work In Progress

This provider type is currently a Work In Progress (WIP) and may be subject to changes as both UTCP and MCP protocols continue to evolve.

Configuration

MCP providers are configured using the following JSON structure:

{
  "name": "mcp_service",
  "provider_type": "mcp",
  "config": {
    "mcpServers": {
      "stdio_server": {
        "transport": "stdio",
        "command": "mcp-server",
        "args": ["--port", "8080"],
        "env": {
          "MCP_API_KEY": "$YOUR_API_KEY"
        }
      },
      "http_server": {
        "transport": "http",
        "url": "https://mcp.example.com/stream"
      }
    }
  },
  "auth": {
    "auth_type": "oauth2",
    "client_id": "$YOUR_CLIENT_ID",
    "client_secret": "$YOUR_CLIENT_SECRET",
    "token_url": "https://auth.example.com/token"
  }
}

Configuration Fields

Field Required Description
name Yes Unique identifier for the provider
provider_type Yes Must be set to "mcp"
config Yes MCP configuration object containing server definitions
config.mcpServers Yes Dictionary of MCP server configurations
auth No Authentication configuration (OAuth2 type)

Transport Types

MCP servers can use different transport mechanisms for communication. Each transport type has specific configuration requirements:

STDIO Transport

For servers connected via standard input/output streams.

Field Required Description
transport Yes Must be "stdio"
command Yes The command to launch the MCP server
args No Command line arguments for the MCP server
env No Environment variables for the MCP server

HTTP Transport

For servers connected via streamable HTTP endpoints.

Field Required Description
transport Yes Must be "http"
url Yes The URL of the MCP server's streaming endpoint

Authentication

MCP providers support OAuth2 authentication for secure communication with MCP servers:

OAuth2 Authentication

{
  "auth": {
    "auth_type": "oauth2",
    "client_id": "$YOUR_CLIENT_ID",
    "client_secret": "$YOUR_CLIENT_SECRET",
    "token_url": "https://auth.example.com/token",
    "scope": "mcp:read mcp:write"
  }
}

Tool Discovery

For MCP providers, UTCP tools are discovered through the MCP server's own discovery mechanism and then automatically mapped to UTCP tool definitions.

MCP Discovery

Tools are discovered using MCP's native tool discovery protocol and capabilities exchange.

UTCP Mapping

MCP tool definitions are automatically translated to UTCP format for seamless integration.

Interoperability

The MCP provider serves as a bridge between UTCP and MCP ecosystems, enabling:

UTCP → MCP

UTCP clients can access tools from MCP servers with automatic protocol translation.

MCP → UTCP

MCP clients can access UTCP tools through an MCP adapter interface.

Tool Call Process

When a tool associated with an MCP provider is called, the following process occurs:

1

Request Translation

Translate the UTCP tool call into MCP tool call format

2

MCP Communication

Send the request to the appropriate MCP server

3

Response Processing

Wait for and process the MCP server's response

4

Response Translation

Translate the MCP response back into UTCP format

5

Result Delivery

Return the result according to the tool's output schema

Examples

AI Model Access

{
  "name": "ai_models",
  "provider_type": "mcp",
  "config": {
    "mcpServers": {
      "llm": {
        "transport": "stdio",
        "command": "mcp-llm-server",
        "args": ["--models", "all"],
        "env": {
          "MODEL_API_KEY": "$YOUR_MODEL_API_KEY"
        }
      }
    }
  }
}

File System Tools

{
  "name": "filesystem",
  "provider_type": "mcp",
  "config": {
    "mcpServers": {
      "fs": {
        "transport": "stdio",
        "command": "mcp-filesystem-server",
        "args": ["--root", "/safe/directory"],
        "env": {
          "FS_READ_ONLY": "false"
        }
      }
    }
  }
}

Web Service Integration

{
  "name": "web_service",
  "provider_type": "mcp",
  "config": {
    "mcpServers": {
      "web": {
        "transport": "http",
        "url": "https://mcp-web-service.example.com/stream"
      }
    }
  },
  "auth": {
    "auth_type": "oauth2",
    "client_id": "$WEB_CLIENT_ID",
    "client_secret": "$WEB_CLIENT_SECRET",
    "token_url": "https://auth.example.com/token"
  }
}

Sample Tool Definition

Example of a tool definition automatically discovered from an MCP server:

{
  "name": "generate_text",
  "description": "Generate text from a prompt using an AI model",
  "inputs": {
    "type": "object",
    "properties": {
      "prompt": {
        "type": "string",
        "description": "The prompt to generate text from"
      },
      "model": {
        "type": "string",
        "description": "Model to use",
        "default": "default-model"
      },
      "max_tokens": {
        "type": "integer",
        "description": "Maximum tokens to generate",
        "default": 100
      }
    },
    "required": ["prompt"]
  },
  "outputs": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string",
        "description": "Generated text"
      }
    }
  }
}

Best Practices

Version Compatibility

  • • Ensure compatibility between UTCP and MCP versions
  • • Test protocol translation with different MCP servers
  • • Monitor for protocol updates and changes

Configuration Management

  • • Use environment variables for sensitive configuration
  • • Properly manage MCP server configurations
  • • Implement configuration validation

Error Handling

  • • Map MCP-specific errors to appropriate UTCP errors
  • • Implement proper retry mechanisms
  • • Log translation errors for debugging

Security

  • • Handle authentication and credentials securely
  • • Implement proper authorization checks
  • • Use secure transport for sensitive operations

© 2024 Universal Tool Calling Protocol. All rights reserved.